class_name GameRandomNumberGenerator

#region 属性
# 随机种子
var seed:int
var rng:RandomNumberGenerator
var last_rng_state = null
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func grng_randf() -> float:
	return rng.randf()
## 含端点
func grng_randf_range(from:float,to:float) -> float:
	return rng.randf_range(from,to)
func grng_randi() -> int:
	return rng.randi()
## 含端点
func grng_randi_range(from:int,to:int) -> int:
	return rng.randi_range(from,to)
func grng_fixed_seed(new_seed = null):
	rng.seed = new_seed if new_seed != null else seed
func grng_randomize():
	update_grng_state()
	rng.randomize()
func update_grng_state():
	last_rng_state = rng.state
func rollback_grng_state():
	if last_rng_state:
		rng.state = last_rng_state
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init(seed:int) -> void:
	self.seed = seed
	rng = RandomNumberGenerator.new()
#endregion
